package com.tengju.data.infrastructure.repository.clickhouse.crm;

import com.tengju.data.domain.model.clickhouse.dashboard.DashBoardMarketInfo;
import com.tengju.data.domain.model.clickhouse.dashboard.DashBoardMarketRespository;
import com.tengju.data.domain.model.clickhouse.dashboard.DashBoardPeopleAnalysisInfo;
import com.tengju.data.domain.model.user.UserIdCode;
import com.tengju.data.infrastructure.persistence.mybatis.dataobject.DashBoardMarketDO;
import com.tengju.data.infrastructure.persistence.mybatis.dataobject.DashBoardPeopleAnalysisDO;
import com.tengju.data.infrastructure.persistence.mybatis.mapper.clickhouse.crm.DashBoardMarketMapper;
import com.tengju.data.infrastructure.repository.clickhouse.convert.DashBoardMarketConvert;
import com.tengju.data.infrastructure.repository.clickhouse.convert.DashBoardPeopleAnalysisConvert;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *
 * @Date: 2021/5/6 17:29
 * @Description:
 */
@Repository
@Slf4j
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class BashBoardMarketRepositoryimpl implements DashBoardMarketRespository {

    private final DashBoardMarketMapper dashBoardMarketMapper;

    //获取品牌销售榜（KA工作台）
    @Override
    public List<DashBoardMarketInfo> getKABrandMarketSort(Integer dateType,
                                                          String startMonth,
                                                          String endMonth,
                                                          String mediumMonth,
                                                          List<Long> idCodeList) {
        List<DashBoardMarketDO> listDO = dashBoardMarketMapper.getKABrandMarketSort(dateType,startMonth,endMonth,mediumMonth,idCodeList);
        return DashBoardMarketConvert.doListToModelList(listDO);
    }

    //获取商品销售榜（SEC工作台）
    @Override
    public List<DashBoardMarketInfo> getSecGoodsMarketSort(Integer dateType,
                                                           String startMonth,
                                                           String endMonth,
                                                           String mediumMonth,
                                                           List<Long> idCodeList) {
        List<DashBoardMarketDO> listDO = dashBoardMarketMapper.getSecGoodsMarketSort(dateType,startMonth,endMonth,mediumMonth,idCodeList);
        return DashBoardMarketConvert.doListToModelList(listDO);
    }

    //人群分析（KA工作台）
    @Override
    public DashBoardPeopleAnalysisInfo getKAPeopleAnalysis(List<Long> idCodeList) {
        List<DashBoardPeopleAnalysisDO> doList = dashBoardMarketMapper.getKAPeopleAnalysis(idCodeList);
        return DashBoardPeopleAnalysisConvert.toModel(doList);
    }

    //人群分析（SEC工作台）
    @Override
    public DashBoardPeopleAnalysisInfo getSECPeopleAnalysis(Long secIdCode) {
        List<DashBoardPeopleAnalysisDO> doList = dashBoardMarketMapper.getSECPeopleAnalysis(secIdCode);
        return DashBoardPeopleAnalysisConvert.toModel(doList);
    }

    //获取品牌销售榜（SEC工作台）
    @Override
    public List<DashBoardMarketInfo> getSECBrandMarketSort(Integer dateType,
                                                           String startMonth,
                                                           String endMonth,
                                                           String mediumMonth,
                                                           List<Long> idCodeList) {
        List<DashBoardMarketDO> listDO = dashBoardMarketMapper.getSECBrandMarketSort(dateType,startMonth,endMonth,mediumMonth,idCodeList);
        return DashBoardMarketConvert.doListToModelList(listDO);
    }

    //获取管辖团队（当月、上月、当前季度）
    @Override
    public List<UserIdCode> getDominationIdCode(Integer dateType, String lastMonthDate, List<Long> idCodeList) {
        List<Long> codeList = dashBoardMarketMapper.getDominationIdCode(dateType,lastMonthDate,idCodeList);
        return DashBoardMarketConvert.toUserIdCodeList(codeList);
    }


}
